<template>
  <div class='container'>
    <el-dialog
      title="预览文章"
      :visible.sync="previewDialogVisible"
      width="50%">

      <h2>{{data.title}}</h2>
      <p>
        <span>{{data.createTime|format}}</span>
        <span style="margin:0 10px">{{data.username}}</span>
        <span style="margin:0 10px"><i class="el-icon-view"></i></span>
        <span>{{data.visits}}</span>
      </p>
      <div class="articlesContainer" v-html="data.articleBody" />
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    data: {
      type: Object,
      required: true
    }
  },
  name: 'preview',
  data () {
    return {
      previewDialogVisible: false
    }
  }
}
</script>

<style scoped lang='less'>
.articlesContainer{
  border-top: 1px dashed #000;
  padding: 10px;
  background-color: #f5f5f5;
  p{
    margin: 14px 0;
  }
}
</style>
